﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.IO;
using ScrumTable.Common.Collections;
using ScrumTable.Common.Reflection;
using ScrumTable.Common.Security;
using ScrumTable.Common.Test;

#endregion

namespace ScrumTable.DL.Data.Local.Test
{
    /// <summary>
    /// Contains the global resources required for the current
    /// test library.
    /// </summary>
    public static class Resources
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        /// <summary>
        /// Gets the test file path for the serialization test.
        /// </summary>
        public const string TempTestFile = "ScrumTable.DL.Data.Local.out.xml";

        /// <summary>
        /// Gets the file name of the test data xml file.
        /// </summary>
        public const string TestDataFile = "ScrumTable.DL.Data.Local.TestData.xml";

        /// <summary>
        /// Gets the file name of the test data xml file.
        /// </summary>
        public static readonly Uri TestUri = new Uri("http://www.example.com");

        public const string Project1Id = "[Project 1]";
        public const string Project2Id = "[Project 2]";

        public const string UserStory1Id = "[WorkItem 1]";
        public const string UserStory2Id = "[WorkItem 2]";
        public const string UserStory3Id = "[WorkItem 3]";
        public const string UserStory4Id = "[WorkItem 4]";

        public const string Iteration1Id = "[Iteration 1]";
        public const string Iteration2Id = "[Iteration 2]";
        public const string Iteration3Id = "[Iteration 3]";

        public const string Task1Id = "[WorkItem 5]";
        public const string Task2Id = "[WorkItem 6]";
        public const string Task3Id = "[WorkItem 7]";
        public const string Task4Id = "[WorkItem 8]";
        public const string Task5Id = "[WorkItem 9]";

        public const string Member1Id = "[Member 1]";
        public const string Member2Id = "[Member 2]";
        public const string Member3Id = "[Member 3]";

        public const string Team1Id = "[Team 1]";
        public const string Team2Id = "[Team 2]";

        public const string Bug1Id = "[WorkItem 10]";
        public const string Bug2Id = "[WorkItem 11]";
        public const string Bug3Id = "[WorkItem 12]";
        public const string Bug4Id = "[WorkItem 13]";
        public const string Bug5Id = "[WorkItem 14]";

        public const string Attachment1Id = "[Attachment 1]";
        public const string Attachment2Id = "[Attachment 2]";
        public const string Attachment3Id = "[Attachment 3]";

        public const string Report1Id = "[Report 1]";
        public const string Report2Id = "[Report 2]";

        public const string Member1Name = @"ba-tfssurface\mgfeller";
        public const string Member2Name = @"ba-tfssurface\pboos";
        public static readonly ConnectionInformation Member1Credentials = new ConnectionInformation(Member1Name, "FooBar");
        public static readonly ConnectionInformation Member2Credentials = new ConnectionInformation(Member2Name, "FooBar");


        public const string BugActiveState = "Active";
        public const string BugClosedState = "Closed";
        public const string BugResolvedState = "Resolved";

        public const string UserStoryActiveState = "Active";
        public const string UserStoryClosedState = "Closed";
        public const string UserStoryInProgressState = "InProgress";
        public const string UserStoryToVerifyState = "Resolved";

        public const string TaskActiveState = "Active";
        public const string TaskInProgressState = "InProgress";
        public const string TaskClosedState = "Closed";


        #region Define Full Element Id Chains

        public static readonly ValueChain<string> FullProject1IdChain = new ValueChain<string>(Project1Id);
        public static readonly ValueChain<string> FullProject2IdChain = new ValueChain<string>(Project2Id);

        public static readonly ValueChain<string> FullIteration1IdChain = new ValueChain<string>(FullProject1IdChain, Iteration1Id);
        public static readonly ValueChain<string> FullIteration2IdChain = new ValueChain<string>(FullProject1IdChain, Iteration2Id);
        public static readonly ValueChain<string> FullIteration3IdChain = new ValueChain<string>(FullProject2IdChain, Iteration3Id);

        public static readonly ValueChain<string> FullUserStory1IdChain = new ValueChain<string>(FullProject1IdChain, UserStory1Id);
        public static readonly ValueChain<string> FullUserStory2IdChain = new ValueChain<string>(FullProject2IdChain, UserStory2Id);
        public static readonly ValueChain<string> FullUserStory3IdChain = new ValueChain<string>(FullIteration1IdChain, UserStory3Id);
        public static readonly ValueChain<string> FullUserStory4IdChain = new ValueChain<string>(FullProject1IdChain, UserStory4Id);

        public static readonly ValueChain<string> FullTask1IdChain = new ValueChain<string>(FullUserStory1IdChain, Task1Id);
        public static readonly ValueChain<string> FullTask2IdChain = new ValueChain<string>(FullUserStory2IdChain, Task2Id);
        public static readonly ValueChain<string> FullTask3IdChain = new ValueChain<string>(FullUserStory2IdChain, Task3Id);
        public static readonly ValueChain<string> FullTask4IdChain = new ValueChain<string>(FullUserStory3IdChain, Task4Id);
        public static readonly ValueChain<string> FullTask5IdChain = new ValueChain<string>(FullUserStory4IdChain, Task5Id);

        public static readonly ValueChain<string> FullMember1IdChain = new ValueChain<string>(FullProject1IdChain, Member1Id);
        public static readonly ValueChain<string> FullMember2IdChain = new ValueChain<string>(FullProject1IdChain, Member2Id);
        public static readonly ValueChain<string> FullMember3IdChain = new ValueChain<string>(FullProject2IdChain, Member3Id);

        public static readonly ValueChain<string> FullTeam1IdChain = new ValueChain<string>(FullProject1IdChain, Team1Id);
        public static readonly ValueChain<string> FullTeam2IdChain = new ValueChain<string>(FullProject1IdChain, Team2Id);

        public static readonly ValueChain<string> FullBug1IdChain = new ValueChain<string>(FullProject1IdChain, Bug1Id);
        public static readonly ValueChain<string> FullBug2IdChain = new ValueChain<string>(FullProject1IdChain, Bug2Id);
        public static readonly ValueChain<string> FullBug3IdChain = new ValueChain<string>(FullUserStory4IdChain, Bug3Id);
        public static readonly ValueChain<string> FullBug4IdChain = new ValueChain<string>(FullUserStory3IdChain, Bug4Id);
        public static readonly ValueChain<string> FullBug5IdChain = new ValueChain<string>(FullIteration3IdChain, Bug5Id);

        public static readonly ValueChain<string> FullAttachment1IdChain = new ValueChain<string>(FullBug3IdChain, Attachment1Id);
        public static readonly ValueChain<string> FullAttachment2IdChain = new ValueChain<string>(FullTask4IdChain, Attachment2Id);
        public static readonly ValueChain<string> FullAttachment3IdChain = new ValueChain<string>(FullUserStory4IdChain, Attachment3Id);

        #endregion


        #region Define Parent Relations

        public static readonly ValueChain<string> UserStory1IdChain = FullUserStory1IdChain.ParentChain;
        public static readonly ValueChain<string> UserStory2IdChain = FullUserStory2IdChain.ParentChain;
        public static readonly ValueChain<string> UserStory3IdChain = FullUserStory3IdChain.ParentChain;
        public static readonly ValueChain<string> UserStory4IdChain = FullUserStory4IdChain.ParentChain;

        public static readonly ValueChain<string> Iteration1IdChain = FullIteration1IdChain.ParentChain;
        public static readonly ValueChain<string> Iteration2IdChain = FullIteration2IdChain.ParentChain;
        public static readonly ValueChain<string> Iteration3IdChain = FullIteration3IdChain.ParentChain;

        public static readonly ValueChain<string> Task1IdChain = FullTask1IdChain.ParentChain;
        public static readonly ValueChain<string> Task2IdChain = FullTask2IdChain.ParentChain;
        public static readonly ValueChain<string> Task3IdChain = FullTask3IdChain.ParentChain;
        public static readonly ValueChain<string> Task4IdChain = FullTask4IdChain.ParentChain;
        public static readonly ValueChain<string> Task5IdChain = FullTask5IdChain.ParentChain;

        public static readonly ValueChain<string> Member1IdChain = FullMember1IdChain.ParentChain;
        public static readonly ValueChain<string> Member2IdChain = FullMember2IdChain.ParentChain;
        public static readonly ValueChain<string> Member3IdChain = FullMember3IdChain.ParentChain;

        public static readonly ValueChain<string> Bug1IdChain = FullBug1IdChain.ParentChain;
        public static readonly ValueChain<string> Bug2IdChain = FullBug2IdChain.ParentChain;
        public static readonly ValueChain<string> Bug3IdChain = FullBug3IdChain.ParentChain;
        public static readonly ValueChain<string> Bug4IdChain = FullBug4IdChain.ParentChain;
        public static readonly ValueChain<string> Bug5IdChain = FullBug5IdChain.ParentChain;

        public static readonly ValueChain<string> Attachment1IdChain = FullAttachment1IdChain.ParentChain;
        public static readonly ValueChain<string> Attachment2IdChain = FullAttachment2IdChain.ParentChain;
        public static readonly ValueChain<string> Attachment3IdChain = FullAttachment3IdChain.ParentChain;

        #endregion


        public const int ProjectCount = 2;
        public const int IterationCount = 3;
        public const int TaskCount = 5;
        public const int UserStoryCount = 4;
        public const int MemberCount = 3;
        public const int BugCount = 5;
        public const int AttachmentCount = 3;
        public const int ReportCount = 2;

        // expect per work item type a workflow, multiply by project count
        public const int TypeCount = 3 * ProjectCount;

        // expect per workflow the following transitions, multiply by project count
        // from UserStory:  4 -> 12 transitions
        // from Task:       3 ->  6 transitions
        // from Bug:        3 ->  4 transitions (Open -> Closed / Closed -> Resolved not allowed)
        public const int TransitionCount = 22 * ProjectCount;

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        public static string GetProjectTestDataFilePath(string testDir)
        {
            return ResourceUtil.CombineToProjectPath(
                testDir,
                TestDataFile);
        }

        public static string GetTestDataFilePath(string testDir)
        {
            return Path.Combine(testDir, TempTestFile);
        }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        #endregion
    }
}
